import requests,unittest

class weidu(unittest.TestCase):
    dljk='http://10.59.9.18'
    sessionId=None
    userId=None
    def test_01_login(self):
        url=weidu.dljk+'/small/user/v1/login'
        json={'phone':'15617293228','pwd':'123456Aa'}
        login=requests.post(url=url,json=json)
        print(login.json())
        weidu.userId=str(login.json()['result']['userId'])
        weidu.sessionId = login.json()['result']['sessionId']
        print(weidu.userId)
        print(weidu.sessionId)
        self.assertEqual(weidu.userId,'35565')
        self.assertNotEqual(weidu.userId,'6544')
        self.assertTrue(weidu.userId == '35565')
        self.assertFalse(weidu.userId=='355565')
        self.assertIn(str(weidu.userId),'355654')
    commodityId=None
    def test_02_commodityList(self):
        url=weidu.dljk+'/small/commodity/v1/commodityList'
        commodityList=requests.get(url=url)
        print(commodityList.json())
        weidu.commodityId=commodityList.json()['result']['rxxp']['commodityList'][0]['commodityId']
        print(weidu.commodityId)
    def test_03_findCommodityDetailsById(self):
        url=weidu.dljk+'/small/commodity/v1/findCommodityDetailsById'
        headsers={'userId':weidu.userId,'sessionId':weidu.sessionId}
        json={'commodityId':weidu.commodityId}
        findCommodityDetailsById=requests.get(url=url,headers=headsers,params=json)
        print(findCommodityDetailsById.json())
    def test_04_browseList(self):
        url=weidu.dljk+'/small/commodity/verify/v1/browseList'
        headsers = {'userId': weidu.userId, 'sessionId': weidu.sessionId}
        json={'page':1,'count':5}
        browseList=requests.get(url=url,headers=headsers,params=json)
        print(browseList.json())
    def test_05_CommodityCommentList(self):
        url=weidu.dljk+'/small/commodity/v1/CommodityCommentList'
        json={'commodityId':weidu.commodityId,'page':1,'count':5}
        CommodityCommentList=requests.get(url=url,params=json)
        print(CommodityCommentList.json())
    def test_06_findRecommendCommodity(self):
        url=weidu.dljk+'/small/commodity/v1/findRecommendCommodity'
        findRecommendCommodity=requests.get(url=url)
        print(findRecommendCommodity.json())


if __name__ == '__main__':
    unittest.main()